<?php
/**
 * Copyright (c) 2006, PORTALIER Julien
 *
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 *
 * @package      FeatherCMS
 * @subpackage   Whatsnew
 * @copyright    Copyright (c) 2006, Julien PORTALIER
 * @link         http://julien.portalier.com
 * @license      http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 */

class PagerController extends Controller
{
	public $uses = null;
	
	function index($file=null)
	{
		$file = $this->__file($file);
		$this->render($file);
	}
	
	function edit($file=null)
	{
		if (!$this->acl->inGroup(Config::admins))
			$this->acl->permissionDenied();
		
		$file = $this->__file($file);
		
		if (empty($this->data))
			$this->data = file_get_contents(APP.'views'.DS.$this->viewPath.DS."$file.thtml");
		else
		{
			file_put_contents(APP.'views'.DS.$this->viewPath.DS."$file.thtml");
			$this->redirect("/home/index/$file");
		}
		
		$this->set('file', $file);
	}
	
	protected function __file($file)
	{
		return empty($file) ? 'index' : basename($file);
	}
}
?>